package com.sls.game.dao.xingxitian.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.impl.SuperDAO;
import com.sls.game.dao.xingxitian.XingChargeTypeDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.xingqitian.XingChargeTypeInfo;

/**
 * 
 * @description
 * @author Wangxuegang
 * @date 2012-12-22
 */
@Repository("xingChargeTypeDAO")
public class XingChargeTypeDAOImpl extends SuperDAO<XingChargeTypeInfo>
		implements XingChargeTypeDAO {

	@Override
	public void insert(XingChargeTypeInfo info) {
		this.getSqlSession().insert("mybatis.xml.XingChargeTypeMapper.insert",
				info);
	}

	@Override
	public Pagination<XingChargeTypeInfo> queryChargeTypeInfo(
			XingChargeTypeInfo info) {
		Pagination<XingChargeTypeInfo> paginationList = null;
		Integer rowCount = queryRowCount(info);
		info.calculate();
		List<XingChargeTypeInfo> list = queryParvalueInfoList(info);
		paginationList = this.queryPagination(rowCount, list, info);
		return paginationList;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(XingChargeTypeInfo info) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.XingChargeTypeMapper.queryRowCount", info);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<XingChargeTypeInfo> queryParvalueInfoList(
			XingChargeTypeInfo info) {
		List<XingChargeTypeInfo> list = this.getSqlSession().selectList(
				"mybatis.xml.XingChargeTypeMapper.queryXQTChargeTypeInfoList",
				info);
		return list;
	}

	@Override
	public XingChargeTypeInfo queryChargeType(XingChargeTypeInfo info) {
		XingChargeTypeInfo chargetype = null;
		chargetype = this.getSqlSession().selectOne(
				"mybatis.xml.XingChargeTypeMapper.queryChargeType", info);
		return chargetype;
	}

	/**
	 * 游戏文件对应编号,查询符合条件的记录
	 * 
	 * @param gametype1
	 * @return
	 */
	@Override
	public List<XingChargeTypeInfo> queryChargeTypeBygametype1(String gametype1) {
		List<XingChargeTypeInfo> list = null;
		list = this.getSqlSession().selectList(
				"mybatis.xml.XingChargeTypeMapper.queryChargeTypeBygametype1",
				gametype1);
		return list;
	}

	/**
	 * 记录详情
	 * 
	 * @param id
	 * @return
	 */
	@Override
	public XingChargeTypeInfo queryChargeTypeById(String id) {
		XingChargeTypeInfo info = null;
		info = this.getSqlSession().selectOne(
				"mybatis.xml.XingChargeTypeMapper.queryChargeTypeById", id);
		return info;
	}
}
